/////////////////////////////////////////////////////////////////////////////////////////////
// Filename: EntityManager.cpp
// (c) Dave Ottley, 2012. All rights reserved.
/////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////
//		INCLUDES
///////////////////////////
#include <assert.h>

///////////////////////////
//		MY INCLUDES
///////////////////////////
#include "EntityManager.h"
#include "BaseGameEntity.h"

EntityManager * EntityManager::GetInstance()
{
	static EntityManager theOne;

	return &theOne;
}

BaseGameEntity * EntityManager::GetEntityFromID(uint32_t id) const
{
	EntityMap::const_iterator ent = mEntityMap.find(id);

	assert((ent != mEntityMap.end()) && "<EntityManager::GetEntityFromID>: invalid ID");

	return ent->second;
}

void EntityManager::RemoveEntity(BaseGameEntity* entity)
{
	mEntityMap.erase(mEntityMap.find(entity->GetID()));
}

void EntityManager::RegisterEntity(BaseGameEntity* newEntity)
{
	mEntityMap.insert(std::make_pair(newEntity->GetID(), newEntity));
}